package cn.smbms.service.user.impl;

import cn.smbms.beans.User;
import cn.smbms.dao.user.UserDao;
import cn.smbms.service.user.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;
/**
 * @ Author   ：陈慧杰
 * @ Date     ：Created in 15:56 2021/12/2
 */
@Service("userService")
public class UserServiceImpl implements UserService {
 @Autowired
 @Qualifier("userDao")
    private UserDao userDao;


    @Override
    public List<User> getUserList(User user , String queryname,String queryUserRole ,Integer currentPageNo, Integer  pageSize) {
      int fromIndex = (currentPageNo -1 ) * pageSize; // 根据当前页码计算当前页要显示的起始位置
        List<User> userList = userDao.getUserList(user ,queryname, queryUserRole,fromIndex,pageSize);
        return userList;
    }



    @Override
    public User login(String userName, String password) {
        User user = userDao.login(userName, password);
        return user;
    }

    @Override
    public int getUserCount(String queryname, String queryUserRole) {
      return   userDao.getUserCount(queryname,queryUserRole);
    }

    @Override
    public int addUser(User user) {
        return userDao.addUser(user);
    }

    @Override
    public User ucExist(String userCode) {

        return userDao.ucExist(userCode);
    }

    @Override
    public int deleteUser(String uid) {
        return  userDao.deleteUser(uid);
    }

    @Override
    public User userView(String uid) {
        return userDao.userView(uid);
    }

    @Override
    public int doUserModify(User user) {
        return userDao.doUserModify(user);
    }

    @Override
    public boolean updatePwd(User user) {
       return  userDao.updatePwd(user);
    }




    @Override
    public String yanPwd(Integer id) {
        return userDao.yanPwd(id);
    }

    @Override
    public int getPwdByUserId(String newpassword, Integer id) {
        return userDao.getPwdByUserId(newpassword,id);
    }


}
